#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T,n[25],m[25],l[25],v[25],d[25][3010],v1[25][3010],a[25][3010],j[25][3010];
	int s2,m2,answer=0,j2[3010],answer1=0;
	cin>>T;
	for(int i=1;i<=T;i++){
		cin>>n[i]>>m[i]>>l[i]>>v[i];
		for(int k=1;k<=n[i];k++){
			cin>>d[i][k]>>v1[i][k]>>a[i][k];
		}
		for(int k=1;k<=m[i];k++){
			cin>>j[i][k];
		}
	}
	for(int i=1;i<=T;i++){
		for(int i2=0;i2<=m[i];i2++){
			j2[i2]=0;
		}
	    for(int q=1;q<=m[i];q++){
		    for(int k=1;k<=m[i]-q;k++){
			    if(j[i][k]>j[i][k+1]){
				    m2=j[i][k];
				    j[i][k]=j[i][k+1];
				    j[i][k+1]=m2;
			    }
		    }
	    }
		for(int k=1;k<=n[i];k++){
			if(a[i][k]>0){
				s2=(v[i]*v[i]-v1[i][k]*v1[i][k])/(2*a[i][k]);
				if(s2+d[i][k]<=j[i][m[i]]){
					answer++;
				}
				for(int i2=1;i2<=m[i];i2++){
					if(d[i][k]<=j[i][i2]&&s2+d[i][k]<=j[i][m[i]]){
						j2[i2]++;
					}
				}
		    }
		    else{
				s2=(v[i]*v[i]-v1[i][k]*v1[i][k])/(2*a[i][k]);
				for(int i2=1;i2<=m[i];i2++){
					if(d[i][k]<=j[i][i2]&&j[i][i2]<=s2){
						answer++;
						break;
					}
				}
				for(int i2=1;i2<=m[i];i2++){
					if(d[i][k]<=j[i][i2]&&j[i][i2]<=s2){
						j2[i2]++;
					}
				}
		    }
		}
	    for(int i2=1;i2<=m[i];i2++){
			if(j2[i2]==0){
				answer1++;
			}
		}
	    cout<<answer<<" "<<answer1;
	}
	return 0;
}
